package cn.darkfire.CarWeb.Utils;

import org.aspectj.lang.JoinPoint;

import java.util.Arrays;

public class Log {
    //使用AOP切面代理来记录执行前、中、后的参数与方法与结果
    //需要导入jar包
    public void before(JoinPoint jp){
        String method = jp.getSignature().getName();
        String params = Arrays.toString(jp.getArgs());
        System.out.println("方法名:"+method+",参数:"+params+"\n");
    }

    public void running(JoinPoint jp,Object running){
        String method = jp.getSignature().getName();
        System.out.println("方法名:"+method+",运行结果:"+running+"\n");
    }

    public void finish(JoinPoint jp){
        String method = jp.getSignature().getName();
        System.out.println("方法名:"+method+",执行完毕\n");
    }

    public void except(JoinPoint jp,Throwable th){
        String method = jp.getSignature().getName();
        System.out.println("方法名:"+method+",异常:"+th+"\n");
    }
}
